package com.yuliang.controller;


import com.yuliang.domain.R;
import com.yuliang.domain.dto.AddLinkDto;
import com.yuliang.domain.dto.UpdateLinkDto;
import com.yuliang.service.LinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/content/link")
public class LinkController {

    @Autowired
    private LinkService linkService;

    @GetMapping("/list")
    public R linkList(Integer pageNum,Integer pageSize,String name,String status){
        return linkService.linkList(pageNum,pageSize,name,status);
    }
    @PostMapping
    public R addLink(@RequestBody AddLinkDto addLinkVo){
        return linkService.addLink(addLinkVo);
    }

    @GetMapping("/{id}")
    public R getLinkDetail(@PathVariable("id") Long id){
        return linkService.getLinkDetail(id);
    }

    @PutMapping
    public R updateLink(@RequestBody UpdateLinkDto updateLinkDto){
        return linkService.updateLink(updateLinkDto);
    }

    @DeleteMapping("{id}")
    public R deleteLink(@PathVariable("id") List<Long> ids){
        return linkService.deleteLink(ids);
    }
    @PutMapping("/changeLinkStatus")
    public R changeLinkStatus(@RequestBody UpdateLinkDto updateLinkDto){
        return linkService.changeLinkStatus(updateLinkDto);
    }
}
